package com.cxh.dataservice.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.cxh.dataservice.config.DataSourceStrategyFactory;
import com.cxh.dataservice.entity.SysUser;
import com.cxh.dataservice.mapper.SysUserMapper;
import com.cxh.dataservice.service.CrownService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cxh.dataservice.service.DataSourceService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author ChenXH
 * @since 2020-07-03
 */
@Service("sysUserService")
@DS("master")
public class CrownServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements CrownService , InitializingBean {

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public List<Map> getData() {
        return sysUserMapper.getData();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        DataSourceStrategyFactory.setData("crown",this);
    }

    @Override
    public List<Map<String, Object>> getData(String sql) {
        return sysUserMapper.query(sql);
    }
}
